﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common
{
    public static class EnumerableExtension
    {
        public static void Dump<T>(this IEnumerable<T> source)
        {
            foreach (var e in source)
            {
                Console.Write("{0}\t",e);
            }
            Console.WriteLine();
        }

        public static void Dump<T>(this IEnumerable<T> source,string message)
        {
            Console.WriteLine(message);
            Dump(source);
        }

        public static IEnumerable<string> Pair(this IEnumerable<string> source)
        {
            string firstHalf = null;
            foreach (string element in source)
                if (firstHalf == null)
                    firstHalf = element;
                else
                {
                    yield return firstHalf + ", " + element;
                    firstHalf = null;
                }
        }
    }
}
